﻿#pragma once

#include "common.h"
#include "settings.h"
#include "seqbase/graphics.h"
#include "vg/primitives.h"
#include "ui/controls.h"

namespace anip
{
	namespace editor
	{
		class Whiteboard : public EditorWindow
		{
		private:
			class Tools;

			Tools* tools;
			ui::Draggable<ui::Canvas>* canvas;

			RenderBuffer* bufMultisample;
			RenderBuffer* bufRestore;

			float ltime = 0, mtime = 0, velocity = 0;
			vec2 mp = { 0, 0 }, lp = { 0, 0 };
			bool mdown = false;

			vg::VgFrameGroup* group = nullptr;
			vg::Stroke* current = nullptr;
			GraphicsRenderContext cxt;
			vec2 oldOffset;

			GraphicsRenderer* renderer;

			void createBuffers();
			void render();

			void addPoint();
			void beginStroke();
			void finishStroke();

		public:
			Whiteboard(Container* parent, invec2 size = { 1000, 700 });

			void setSize(invec2 size) override;
			void paint() override;

			~Whiteboard();
		};
	}
}